package org.opengauss.datachecker.extract.task;

import oracle.jdbc.OracleType;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class OracleResultSetHandler extends ResultSetHandler{
    private final Map<OracleType, TypeHandler> typeHandlers = new ConcurrentHashMap<>();
    {
        //date timestamp
        typeHandlers.put(OracleType.DATE,this::getDateFormat);
        typeHandlers.put(OracleType.TIMESTAMP,this::getTimestampFormat);

        //Bit
        
    }
    @Override
    protected String convert(ResultSet resultSet, String columnTypeName, String columnLabel, int displaySize) throws SQLException {
        if(typeHandlers.containsKey(columnTypeName)){
            return typeHandlers.get(columnTypeName).convert(resultSet,columnLabel,displaySize);
        } else {
            return resultSet.getObject(columnLabel).toString();
        }
    }
}
